AS=/usr/local/mips-cross/bin/mipsel-elf-as
CC=/usr/local/mips-cross/bin/mipsel-elf-gcc
LD=/usr/local/mips-cross/bin/mipsel-elf-ld
OBJCOPY=/usr/local/mips-cross/bin/mipsel-elf-objcopy
OBJDUMP=/usr/local/mips-cross/bin/mipsel-elf-objdump

# fno-delayed-branch is mandatory for this processor as we do NOT have branch delay slots
CFLAGS=-mips1 -fomit-frame-pointer -fno-delayed-branch -nodefaultlibs -nostartfiles -nostdlib -membedded-data -mno-mips16

INCLUDE=-I../../include/

all:
	$(CC) test.c -c $(CFLAGS) $(INCLUDE) -o test.o
	$(AS) -mips1 bootloader.S -o bootloader.o -EL -g
	$(LD) -mips1 -T ../../lib/default.ld test.o bootloader.o -o test.elf -EL -g
	$(OBJCOPY) -j .startup.bootvec -j .startup -j .rodata -O binary test.elf test.bin
	hexdump -e "1/4 \"%08x\n\"" test.bin -v > test.hex
	cat ../../lib/nops.hex >> test.hex

dump:
	$(OBJDUMP) -j .startup.bootvec -j .startup -S -D test.elf -z

symbols:
	$(OBJDUMP) -t test.elf

sections:
	$(OBJDUMP) -h test.elf

clean:
	rm -f test.bin test.elf test.hex test.o bootloader.o
